class Bloom extends egret.Shape
{
    public r;
    public c;
    public pc;
    public petals: Petal[] = [];
    public garden: Garden;
    public constructor(vector,radius,rgba,count,garden = null)
    {
        super();
        this.r = radius;
        this.c = rgba;
        this.pc = count;
        this.garden = garden;
        this.init();
        this.x = vector.x;
        this.y = vector.y;
        if(garden)
        {
            this.garden.addBloom(this);
        }
    }
    public draw()
    {
        var b;
        //this.garden.save();
        //var matrix = new egret.Matrix;
        //matrix.translate(this.p.x,this.p.y);
        //var t = new egret.Transform(this.garden);
        //t.matrix = matrix;
        //this.garden.translate(this.p.x,this.p.y);
        for(var a = 0;a < this.petals.length;a++)
        {
            var c = this.petals[a];
            c.render();
            b = c.isfinished;
        }
        //this.garden.graphics.restore();
        if(b == true)
        {
            if(this.garden)
            {
                this.garden.removeBloom(this);
            }
        }
    }
    public init()
    {
        var angle = 360 / this.pc;
        for(var a = 0;a < this.pc;a++)
        {
            var stretchA = Garden.random(Garden.options.petalStretch.min,Garden.options.petalStretch.max);
            var stretchB = Garden.random(Garden.options.petalStretch.min,Garden.options.petalStretch.max);
            var startAngle = Garden.randomInt(0,90) + a * angle;
            var growFactor = Garden.random(Garden.options.growFactor.min,Garden.options.growFactor.max);
            this.petals.push(new Petal(stretchA,stretchB,startAngle,angle,growFactor,this));
        }
    }
}